# api/utils/response.py
from flask import jsonify

class ApiResponse:
    @staticmethod
    def success(data=None, message="成功", code=0):
        """
        成功响应
        """
        return jsonify({
            "code": code,
            "message": message,
            "data": data if data is not None else {}
        })

    @staticmethod
    def error(message="失败", code=-1, data=None):
        """
        错误响应
        """
        return jsonify({
            "code": code,
            "message": message,
            "data": data if data is not None else {}
        })

# 快捷函数（可选）
success = ApiResponse.success
fail = ApiResponse.error
error = ApiResponse.error